package LeetCode;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}15:41
 */
public class LeetCode999 {
    public static void main(String[] args) {

    }

    public int numRookCaptures(char[][] board) {
        int count = 0;
        int row = 0;
        int clow = 0;
        ok:
        for (int i = 0; i < board.length;i++){
            for (int j = 0; j < board[i].length; j++){
                if (board[i][j]=='R'){
                    row = i;
                    clow = j;
                    break ok;
                }
            }
        }

        for (int i = clow; i >=0; i--){
            if (board[row][i]=='p'){
                count++;
                break;
            }else if(board[row][i]=='B'){
                break;
            }
        }
        for (int i = clow; i < board[row].length; i++){
            if (board[row][i]=='p'){
                count++;
                break;
            }else if(board[row][i]=='B'){
                break;
            }
        }

        for (int i = row; i >= 0; i--){
            if (board[i][clow]=='p'){
                count++;
                break;
            }else if(board[i][clow]=='B'){
                break;
            }
        }

        for (int i = row; i < board.length; i++){
            if (board[i][clow]=='p'){
                count++;
                break;
            }else if(board[i][clow]=='B'){
                break;
            }
        }
        return count;
    }
}
